package com.fuxue.mapper;

import com.fuxue.dto.CollectionDTO;
import com.fuxue.dto.CollectionPageDTO;
import com.fuxue.dto.ForumDTO;
import com.fuxue.dto.KnowledgeDTO;
import com.fuxue.entity.AnswerAll;
import com.fuxue.vo.*;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ForumMapper {

    Page<ForumVO> SelectQuestion(ForumDTO forumDTO);

    Page<ForumAnswerVO> SelectAnswer(ForumDTO forumDTO);

    @Select("select answer_id,server_name,server_avatar,context,creat_time from answer " +
            "where answer_id = #{aId}")
    AnswerDetialsVO getAnswerDetials(int aId);
/*
     服务者发布帖子
 */
    @Insert("insert into answer (q_id,server_id,server_name,server_avatar,context,creat_time,title,type)"+
    "values"+"(#{qd},#{serverId},#{serverName},#{serverAvatar},#{context},#{creatTime},#{title},#{type})")
    void setKnoledge(KnowledgeDTO knowledgeDTO);
    @Select("SELECT MAX(answer_id) FROM answer; ")
    Integer selectId();

    @Select("select * from answer where answer_id = #{id}")
    AnswerAll getKnowledgeVO(Integer id);
    @Select("select url from image where aq_id = #{id} and type = 1")
    List<String> getImage(Integer id);

    @Insert("insert into collection (aq_id, aq_type, pepole_id, pepole_type, creat_time) " +
            "values (#{aqId},#{aqType},#{pepoleId},#{pepoleType},#{creatTime})")
    void newCollection(CollectionDTO collectionDTO);

    Page<CollectonVO> SelectQuestionCollection(CollectionPageDTO collectionPageDTO);

    Page<CollectionAnswerVO> SelectAnswerCollection(CollectionPageDTO collectionPageDTO);
}
